home *** CD-ROM | disk | FTP | other *** search
- {
- PROGRAM - COPY.PAS
-
- PURPOSE - 1. Demo of Personal Pascal Printer, Disk, and Console I/O
-
- 2. Do a reasonable job of printing files.
-
- PROBLEMS - may be somewhat naive about screen control characters, like BS.
-
- I took this example program and embellished it to do a little GEM. Seems like
- hardly no one is doing pascal out there. Like to change that!
-
- Oh, please excuse the goto. I is an old Fortran programmer, and don't know no
- better!
- }
-
- program copy (input, output, input_file, output_file);
-
- label 2;
-
- const
- {$I GEMCONST.PAS}
-
- type
- {$I GEMTYPE.PAS}
- character = -1..127;
-
- var
- Alert_string, In_Name, Out_Name, Def_path: Str255;
- Choice, Which : integer;
- Dummy : char;
- C : Character;
- End_Line : Boolean;
- Input_File, Output_File : File of Text;
-
- {$I GEMSUBS}
-
- function current_disk : integer;
- gemdos($19);
-
- function getc (var c : character) : character;
- var
- ch : char;
- begin
- End_Line := eoln(input_file);
- If not eof(input_file) then begin
- read(input_file,ch);
- c := ord(ch)
- End;
- getc := c
- end;
-
- procedure putc(c : character);
- begin
- if End_Line then
- begin
- writeln(output_file,chr(c));
- End_Line := false;
- end
- else
- write(output_file,chr(c));
- end;
-
- begin
- End_Line := false;
- If INIT_GEM >= 0 then
- begin
- Alert_string := '[0][ The Copy Procedure | | From the book | ';
- Alert_string := Concat(Alert_string, 'Software Tools in Pascal | ');
- Alert_string := Concat(Alert_string, ' by Kernighan & Plauger ][ OK ]');
- Choice := Do_alert(Alert_string,0);
- Alert_string := '[0][ Modified for the ST | by The Vaxrat | ';
- Alert_string := Concat(Alert_string, 'Parts c1986 OSS & CCD. | ');
- Alert_string := Concat(Alert_string, ' Used with Permission | ]');
- Alert_string := Concat(Alert_string, '[ Sure ]');
- Choice := Do_alert(Alert_string,1);
- Alert_string := '[0][ Call the Webbed Sphere! | (513) 299-3665 | ';
- Alert_string := Concat(Alert_string,'300/1200 Baud 24 hrs a day | ');
- Alert_string := Concat(Alert_string,'Tell Webby Vaxrat sent ya! | ]');
- Alert_string := Concat(Alert_string,'[ Get on with it! ]');
- Choice := Do_alert(Alert_string,1);
- Alert_string := '[2][ | Select Input Source | ]';
- Alert_string := Concat(Alert_string, '[ Disk | Keys ]');
- Choice := Do_alert(Alert_string,0);
- If Choice = 1 then
- Begin
- IN_Name := '';
- which := current_disk;
- case which of
- 1 : Def_path := 'B:\*.TXT';
- 2 : Def_path := 'C:\*.TXT';
- 3 : Def_path := 'D:\*.TXT';
- otherwise : Def_path := 'A:\*.TXT'
- End;
- If Not Get_in_file(Def_path, IN_Name) Then
- GOTO 2;
- Reset(Input_file, in_name);
- end
- else
- Reset(Input_file, 'CON:');
- Alert_string := '[0][ Select Output Source | ]';
- Alert_string := Concat(Alert_string, '[ Disk | LPR | Mon ]');
- Choice := Do_alert(Alert_string,0);
- Case Choice of
- 1 : Begin
- If Not Get_Out_File('Output File Name?',Out_Name) Then
- Goto 2;
- Rewrite(Output_file,out_name)
- End;
- 2 : Begin
- Out_Name := 'PRN:';
- Alert_string := '[1][ Ready to Print! | Make sure that the |';
- Alert_string := Concat(Alert_string,' Printer is Ready! ]');
- Alert_string := Concat(Alert_string,'[ Ok | Abort ]');
- Which := Do_alert(Alert_string,0);
- If which = 2 then
- Goto 2;
- Rewrite(Output_file,out_name);
- writeln(output_file,chr(27),chr(78),chr(6))
- End;
- 3 : Begin
- Out_Name := 'CON:';
- Alert_string := '[1][ Ready to Print! | | Use Control-S/Q to |';
- Alert_string := Concat(Alert_string,' Stop Scrolling. ]');
- Alert_string := Concat(Alert_string,'[ Ok | Abort ]');
- Which := Do_alert(Alert_string,0);
- If which = 2 then
- Goto 2;
- Rewrite(Output_file,out_name);
- Hide_Mouse;
- Clear_Screen;
- End
- End
- End;
- while not eof(input_file) do
- begin
- c := getc(c);
- putc(c)
- end;
- 2 :Case Choice of
- 3 : Begin
- Writeln(output_file);
- Writeln('Press <RETURN> to continue...');
- Read(dummy)
- End;
- 2 : Writeln(Output_file,chr(12))
- End;
- Close(output_file);
- Show_Mouse;
- Exit_Gem
- End.
- əəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəə